/**
 * - 获取views目录下的所有子目录的.vue文件的导出内容
 * @returns
 */
const get_glob_view = () => {
  const compContent = import.meta.glob(`/src/views/**/*.vue`, {
    eager: true,
    import: "default",
  }) as Record<string, any>;

  const components = import.meta.glob(`/src/views/**/*.vue`);
  return {
    compContent,
    components,
  };
};

/**
 * - 获取components目录下的所有子目录的.vue文件的导出内容
 * @returns
 */
const get_glob_component = () => {
  const compContent = import.meta.glob(`/src/components/**/*.vue`, {
    eager: true,
    import: "default",
  }) as Record<string, any>;

  const components = import.meta.glob(`/src/components/**/*.vue`);
  return {
    compContent,
    components,
  };
};

/**
 * - 获取pages目录下的所有子目录的.vue文件的导出内容
 * @returns
 */
const get_glob_page = () => {
  const compContent = import.meta.glob(`/src/pages/**/*.vue`, {
    eager: true,
    import: "default",
  }) as Record<string, any>;

  const components = import.meta.glob(`/src/pages/**/*.vue`);
  return {
    compContent,
    components,
  };
};

/**
 * - 获取layouts目录下的所有子目录的.vue文件的导出内容
 * @returns
 */
const get_glob_layout = () => {
  const compContent = import.meta.glob(`/src/layouts/**/*.vue`, {
    eager: true,
    import: "default",
  }) as Record<string, any>;

  const components = import.meta.glob(`/src/layouts/**/*.vue`);
  return {
    compContent,
    components,
  };
};

// - 目录映射
const directory_map = {
  views: get_glob_view,
  components: get_glob_component,
  pages: get_glob_page,
  layouts: get_glob_layout,
};

export {
  directory_map
};
